export const formatHour = hour => hour.toString().length > 1 ? hour : `0${hour}`;

export const getWorkingHourslist = () => {
  const hours = [];

  for (let i=8; i<=18; i++) {
    const value = formatHour(i);
    hours.push({
      label: value,
      value
    });
  }

  return hours;
}

export const getWorkingWeeks = () => ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];

export const validate = (form = {}, data = {}, fields = []) => {
  let isValidated = true;

  fields.map(field => {
    const ele = document.getElementById(field);
    const val = data[field];

    if (!val && val !== 0 && isValidated) {
      form.showErrorTips({ ele, msg: 'empty' });
      isValidated = false;
    }
  });

  return isValidated;
};
